home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgLangD.iso / BORLAND TURBO / 32SNIPIT.PAK / TBLINFO.C < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-06  |  4.3 KB  |  126 lines

  1. // BDE32 3.x - (C) Copyright 1996 by Borland International
  2.  
  3. // TblInfo.c
  4. #include "snipit.h"
  5.  
  6. // Name of table
  7. static const char szTblName1[] = "orders";
  8. // Table type to use.
  9. static const char szTblType1[] = szPARADOX;
  10.  
  11. //=====================================================================
  12. //  Function:
  13. //          TblInfo();
  14. //
  15. //  Description:
  16. //          This example displays information about a table, including:
  17. //          fields, indexes, validity checks, referential integrity,
  18. //          and security descriptors.
  19. //=====================================================================
  20. void
  21. TblInfo (void)
  22. {
  23.     hDBIDb      hDb;        // Handle to the database
  24.     hDBICur     hListCur;   // Cursor handle used for the lists of
  25.                             // information
  26.     DBIResult   rslt;
  27.  
  28.     Screen("*** Getting Table Information ***\r\n");
  29.  
  30.     BREAK_IN_DEBUGGER();
  31.  
  32.     Screen("    Initializing IDAPI... ");
  33.     if (InitAndConnect(&hDb) != DBIERR_NONE)
  34.     {                                        
  35.         Screen("*** End of Example ***");
  36.         return;
  37.     }
  38.  
  39.     Screen("    Setting the database directory...");
  40.     rslt = DbiSetDirectory(hDb, (pCHAR) szTblDirectory);
  41.     ChkRslt(rslt, "SetDirectory");
  42.  
  43.     Screen("    Get the fields for the %s table...", szTblName1);
  44.     rslt = DbiOpenFieldList(hDb, (pCHAR) szTblName1, (pCHAR) szTblType1,
  45.                             FALSE, &hListCur);
  46.     ChkRslt(rslt, "OpenFieldList");
  47.  
  48.  
  49.     Screen("    Display the fields of the %s table as IDAPI types...",
  50.            szTblName1);
  51.     DisplayInMemoryTable(hListCur, 0);
  52.  
  53.     Screen("\r\n    Close the schema table...");
  54.     rslt = DbiCloseCursor(&hListCur);
  55.     ChkRslt(rslt, "CloseCursor");
  56.  
  57.     Screen("    Get the list of indexes on the %s table...", szTblName1);
  58.     rslt = DbiOpenIndexList(hDb, (pCHAR) szTblName1, (pCHAR) szTblType1,
  59.                             &hListCur);
  60.     ChkRslt(rslt, "OpenIndexList");
  61.  
  62.     Screen("    Display the indexes on the %s table...", szTblName1);
  63.     DisplayInMemoryTable(hListCur, 0);
  64.  
  65.     Screen("\r\n    Close the schema table...");
  66.     rslt = DbiCloseCursor(&hListCur);
  67.     ChkRslt(rslt, "CloseCursor");
  68.  
  69.     Screen("    Get the validity checks for the %s table...",
  70.            szTblName1);
  71.     rslt = DbiOpenVchkList(hDb, (pCHAR) szTblName1, (pCHAR) szTblType1,
  72.                            &hListCur);
  73.     ChkRslt(rslt, "OpenVchkList");
  74.  
  75.     Screen("    Display the validity checks of the %s table...", szTblName1);
  76.     DisplayInMemoryTable(hListCur, 0);
  77.  
  78.     Screen("\r\n    Close the schema table...");
  79.     rslt = DbiCloseCursor(&hListCur);
  80.     ChkRslt(rslt, "CloseCursor");
  81.  
  82.     Screen("    Get the referential integrity links for the %s table...",
  83.            szTblName1);
  84.     rslt = DbiOpenRintList(hDb, (pCHAR) szTblName1, (pCHAR) szTblType1,
  85.                            &hListCur);
  86.     ChkRslt(rslt, "OpenRintList");
  87.  
  88.     Screen("    Display the referential integrity links for the %s table...",
  89.            szTblName1);
  90.     DisplayInMemoryTable(hListCur, 0);
  91.  
  92.     Screen("\r\n    Close the schema table...");
  93.     rslt = DbiCloseCursor(&hListCur);
  94.     ChkRslt(rslt, "CloseCursor");
  95.  
  96.     Screen("    Get the security descriptors for the %s table...", szTblName1);
  97.     rslt = DbiOpenSecurityList(hDb, (pCHAR) szTblName1, (pCHAR) szTblType1,
  98.                                &hListCur);
  99.     ChkRslt(rslt, "OpenSecurityList");
  100.  
  101.     Screen("    Display the security descriptors for the %s"
  102.            " table...", szTblName1);
  103.     DisplayInMemoryTable(hListCur, 0);
  104.  
  105.     Screen("\r\n    Close the schema table...");
  106.     rslt = DbiCloseCursor(&hListCur);
  107.     ChkRslt(rslt, "CloseCursor");
  108.  
  109.     Screen("    Get the family list for the %s table...", szTblName1);
  110.     rslt = DbiOpenFamilyList(hDb, (pCHAR) szTblName1, (pCHAR) szTblType1,
  111.                              &hListCur);
  112.     ChkRslt(rslt, "OpenFamilyList");
  113.  
  114.     Screen("    Display the family list for the %s table...", szTblName1);
  115.     DisplayInMemoryTable(hListCur, 0);
  116.  
  117.     Screen("\r\n    Close the schema table...");
  118.     rslt = DbiCloseCursor(&hListCur);
  119.     ChkRslt(rslt, "CloseCursor");
  120.  
  121.     Screen("    Close the database and exit IDAPI...");
  122.     CloseDbAndExit(&hDb);
  123.  
  124.     Screen("\r\n*** End of Example ***");
  125. }
  126.